<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%
  String personUuid=request.getParameter("personUuid");
String path = request.getContextPath();
%>
<script>

window.iwbUsername="<%=personUuid%>";

var currentPage=1;
var lock=true;
var nsMoreClicked;
var pageEnd=false;//是否已经到最后一页了，没办法再翻页了
var pageCount=1;//自动查看下一页的次数，超过3次就不自动翻页了
// 查看下一屏数据以及滚动到顶部
$(function () {
    onScroll = function () {
    	if(pageEnd){
    	  return;
    	}
    	 
    	if(pageCount>3){
    	  return;
    	}
        var windowHeight = document.body.offsetHeight;
        var currentScroll = document.documentElement.scrollTop || document.body.scrollTop;
        var visableHeight = document.documentElement.clientHeight;
       // alert("height:"+(visableHeight + currentScroll)+"  wHeight:"+windowHeight);
        if( (visableHeight + currentScroll) >= windowHeight ){
         if ( !nsMoreClicked || (new Date().getTime() - nsMoreClicked) > 1500 ) {
		     nsMoreClicked = new Date().getTime();
		 } else {
		     return;
		 }
        
             getMore();
        }
    };
    
    if( window.attachEvent ){
        window.attachEvent("onscroll",onScroll,false);
    }else{
        window.addEventListener('scroll',onScroll,false);
    }
    
   
  //  window.onScroll = onScroll;
});
 
 
 function getMore() {
	    var ns = $(".nextscreen");
	    var nsMore = ns.find(".stext");
	     var nsLoading = ns.find(".loading");
        nsMore.hide();
        nsLoading.show();
         if(pageEnd){
            alert("没有下一页了");
        	ns.hide();
        	return;
         }
         currentPage++;
          getJsonMessage(currentPage);
  		nsMore.show();
        nsLoading.hide();
          pageCount++;
          lock=true;
  } ;

function getJsonMessage(pageno){

lock=false;
var url="/sapfree/servlet/MessageBoradServlet?method=ajaxGetMessageByPersonId&personUuid=<%=personUuid%>";
if(pageno!=null&&pageno!=""){
   url+='&pageno='+pageno;
}
	 $.ajax({
			url: url,
			dataType: 'text',
			type: "post",
			error:function(XMLHttpRequest,textStatus,errorThrown){alert(errorThrown);},
			success: function(data) {
			 if(data.length==2){
			   pageEnd=true;
			   var ns = $(".nextscreen");
			   ns.hide();
			   
			   return;
			 }
			     initTable(data);
			    $("#wait").hide();
			}
		});
}

function initTable(data){
 //  $('.tmessage').remove();
	data=eval(data);
	 var s="";
	 
	 if(data.length<10){
	   pageEnd=true;
	   var ns = $(".nextscreen");
	   ns.hide();
	 }
      for(i=0;i<data.length;i++){
          s+=initTr(data[i]);
      }   
      $("#tmain").append(s);  
      addUCard();
}
var bTime;
function addUCard(){
   $(".personLink").hover(function(){
     if(bTime!=null){
	  clearTimeout(bTime); 
	 }
	 var href=this.href;
	 
	 getPersonInfo(href);
     $("#uCard").css("top",getTop(this)+30);
     $("#uCard").css("left",getLeft(this)-5);
     $("#uCard").show();
   },
   function(){
      bTime=setTimeout(function(){$("#uCard").hide()},1000);
    });
   
   $('#uCard').hover( 
    function() {
   			if(bTime!=null){
  			 clearTimeout(bTime); 
  			 }
			$('#uCard').show();
	}, function() {
			setTimeout(function(){$("#uCard").hide()},500);
	});
}

var person=new Array();
function getPersonInfo(hrefUrl){
   var i=hrefUrl.indexOf("?email=");
   if(i>-1){
  	  var email=hrefUrl.substring(i+7,hrefUrl.length);
  	  var url="/sapfree/servlet/MessageBoradServlet?method=getPersonByEmail&email="+email;
	  $.ajax({
			url: url,
			dataType: 'text',
			type: "post",
			error:function(XMLHttpRequest,textStatus,errorThrown){alert(errorThrown);},
			success: function(data) {
			    initUCard(data);
			 }
		});
   }else{
       
   }
}

function initUCard(data){
    
}
//y
function getTop(e){
	var offset=e.offsetTop;
	if(e.offsetParent!=null) offset+=getTop(e.offsetParent);
	return offset;
}

//x
function getLeft(e){
	var offset=e.offsetLeft;
	if(e.offsetParent!=null) offset+=getLeft(e.offsetParent);
	return offset;
}
	
	
function initTr(message){
    var s="";
   /* s+="<tr class='message'> <td width=\"10\" align=\"right\"></td>";
    s+="<td height=\"30\" colspan=\"2\" align=\"left\" class=\"blackNormal12\">";
    s+="<a href=\"../personPage/personHome.html\" target=\"_blank\"><span class=\"lightBlueNormal12\">";
    s+="【"+message.cc_perosnname+"】</span></a> ";
    s+=faceReplaceImg(message.cc_commentcontent)+"<span class=\"greyNormal12\">&nbsp;&nbsp;（";
    s+=message.cc_commenttime+"）</span></td></tr>";*/
  
    var imagurl = '<%=path%>/servlet/FileUploadManagerServlet?method=showImage&imgPath='+message.pi_yszhaopian;
    var personUrl='<%=path%>/person/personarea?personuuid='+message.cc_personuuid;
    s+='<li  class="tmessage" style="background-color: rgb(255, 255, 255);width:100%;"><div class="extra"></div>';
    s+=' <div class="ttouxiang">';
    s+='  <a title="'+message.cc_perosnname+'" class="timelineUsercard" href="'+personUrl+'">';
    s+='  <img  src="'+imagurl+'" width="36" height="36">';
    s+='</a></div>'; 
     

	    s+='  <div class="tbody"> <a href="'+personUrl+'" class="tname personLink"    target="_blank">'+message.cc_perosnname+'</a>';
	    s+='<span>：</span>';
	    s+='<span>'+faceReplaceImg(message.cc_commentcontent)+'</span>';
	if(message.cc_smallimage!=""&&message.cc_smallimage != undefined){
	    s+='<div class="iwbImageView"> <div class="imageLoading">';
	    s+=' <div class="imageLoadingIcon"></div></div>';
	    s+='<img src="<%=path%>/servlet/FileUploadManagerServlet?method=showImage&imgPath='+message.cc_smallimage+'" data-imagehuge="<%=path%>/servlet/FileUploadManagerServlet?method=showImage&imgPath='+message.cc_image+'"';
	    s+='   data-imagebig="<%=path%>/servlet/FileUploadManagerServlet?method=showImage&imgPath='+message.cc_image+'" class="imageViewSmall">';
	    s+='</div>';
     }       
    s+='<div class="tbottom"><div class="tbottomleft"><a class="time" href="javascript:void(0);">'+message.cc_commenttime+'</a>';
    s+=' <a href="javascript:void(0);" class="tchakan"  data-reid="'+message.cc_uuid+'">查看评论 </a></div> ';
    s+='<div class="tbottomright"> ';
    s+='  <a href="javascript:void(0);" class="tdianping" data-mcount="0" data-reid="'+message.cc_uuid+'" >评论</a>';
    s+='<span class="tactionsp">|</span><a onclick="return false;" class="more" href="javascript:void(0);return false;">';
    s+='<em>更多<small class="icon_down">1</small></em><ul>';
    s+=' <li href="javascript:void(0);" class="tshanchu" >删除</li>';
    s+=' <li onclick="msgDetail(\''+message.cc_uuid+'\')"  >详情</li>  ';
    s+='  </ul></a></div></div></div></li>';
    return s;

}
function msgDetail(cc_uuid){
	var url='<%=path%>/servlet/MessageBoradServlet?method=msgDetail&msgId='+cc_uuid;
	window.open(url);
}

</script>
 <style>
 .uCard {
    background: none repeat scroll 0 0 #EFEFEF;
    border: 1px solid #CFCFCF;
    margin: -9px 0 0 -9px;
    padding: 2px;
    position: absolute;
    text-align: left;
    z-index: 99;
}
.uCardcnt, .uloadBox {
    background-color: #FFFFFF;
    color: #999999;
    min-height: 81px;
    overflow-x: hidden;
    padding: 4px 6px 0 64px;
    width: 174px;
}
 
.uCard .userPic {
    padding: 6px 0 0 6px;
    position: absolute;
    width: 58px;
}
.userPic {
    float: left;
    padding: 4px 15px 4px 10px;
}

.uCard .userName {
    color: #333333;
    float: none;
    height: auto;
    line-height: 19px;
    white-space: nowrap;
}
.uCardcnt, .uloadBox {
    background-color: #FFFFFF;
    color: #999999;
    min-height: 81px;
    overflow-x: hidden;
    padding: 4px 6px 0 64px;
    width: 174px;
}
.uCard .userName {
    color: #333333;
    float: none;
    height: auto;
    line-height: 19px;
    white-space: nowrap;
}
.uCardcnt .btn, .uCard .nickFun {
    padding-left: 1px;
    position: absolute;
    right: 8px;
    top: 64px;
    z-index: 1;
}
.uCardcnt .btn, .uCard .nickFun {
    padding-left: 1px;
    position: absolute;
    right: 8px;
    top: 64px;
    z-index: 1;
}
 .uCardcnt .btn a,.uCard .delAttention {
    background: url("<%=path%>/images/b2_120112.png") no-repeat scroll 0 0 transparent;
}
.uCard .delAttention, .attentBox .delAttention {
    background-position: -29px -428px;
    float: left;
    height: 18px;
    padding-left: 24px;
}
.uCardcnt .btn a {
    background-position: -80px -408px;
    border: 1px solid #DFDFDF;
    color: #333333;
    display: inline-block;
    height: 15px;
    line-height: 15px;
    margin-left: -1px;
    padding: 0 7px 0 8px;
}

 .uCard .userPic .btn, .attentBox {
    height: 18px;
    line-height: 23px !important;
    overflow: hidden;
    padding: 3px 0 0;
    text-align: left !important;
    white-space: nowrap;
    width: 50px;
}

 </style>
<!-- 
      <table id="messageBorad" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#FFFFFF">
          <tr><td height="10"></td></tr>
         
          <tr id="wait"> <td width="10" align="right"></td>
             <td height="30" style="font-size:12px" align=center><img src="<%=path %>/include/images/loading.gif" /> 加载……</td>
             <td width="10" align="right"></td>
          </tr>
          
 </table>   -->
 
 <div class="tcontainer"  >
 
 <ul id="tmain" class="tmain" >
 
  
  
 </ul>
 </div>
 <div class="pagerwrapper">
    <div class="nextscreen">
        <div class="loading hide"><b class="icon_loading"></b><label>正在加载...</label></div>
        <a href="javascript:void(0);" class="stext" onclick="getMore()"><label>查看更多<b class="icon_arrowdown"></b></label></a>
    </div>
</div>


<div class="uCard cType2 cardT" style="left: 322px; top: 416px;display:none;" id="uCard" >
<div class="userPic">
<a href="http://t.qq.com/QQGame"><img widht="48" height="48" src="<%=path %>/servlet/FileUploadManagerServlet?method=showImage&imgPath=2012-02-01/7e01dcc5-4386-45d8-a3be-5cc456ba4edc_small.jpg"></a>
 <p class="btn">
      <a title="取消收听" class="delAttention" href="#" style="display: block;">取消<i class="l"></i></a>
  </p>
</div>
<div class="uCardcnt">
<p class="userName"><a href="http://t.qq.com/QQGame">张凯</a><a class="tIcon ico_cvip" target="_blank" title="腾讯机构认证" href="http://t.qq.com/certification"></a><br><span class="en">@张凯(samtyou@md.so)</span></p>


<p class="btn"><a class="reply" href="#">对话</a><a class="msg disabled" href="#" title="私信只能发给你的听众">私信</a><a class="chat disabled" href="#">聊天</a><a class="more" href="javascript:void(0)">更多<em class="btn_ldrop"></em></a></p>
</div>
</div>

 <script>
 getJsonMessage();
 </script>